<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/9
 * Time: 14:19
 */

namespace src;


use conf\Config;

class Ask
{
    public static $index = 0;
    public $_data;
    public static $_list;

    public function __get($name)
    {
        // TODO: Implement __get() method.
        return isset($this->_data[$name]) ? $this->_data[$name] : '';
    }

    public function __set($name, $value)
    {
        // TODO: Implement __set() method.
        return $this->_data[$name] = ($value);
    }

    public function commit(){
        self::$_list[] = $this->_data;
    }

    public function save(){
            $this->index();
    }

    public function index(){
        if(count(self::$_list) > 100 ){
            $path = Config::$PATH_TMP;
            $log = $path."/ask_".self::$index.".data";
            $a = serialize(self::$_list);
            file_put_contents($log,$a);
            self::$_list = [];
            self::$index++;
        }
    }

}